import App from './App'
import $U from './common/util.js'
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
import store from './store'
import $H from './common/request.js';
Vue.config.productionTip = false
Vue.prototype.$U = $U;
Vue.prototype.$H = $H;
// 登录校验
Vue.prototype.checkAuth = (callback,checkPhone=true)=> {
	if(!store.state.loginStatus) {
		uni.showToast({
			title:'请先登录',
			icon:'error'
		})
		return uni.navigateTo({
			url:'/pages/login/login'
		})
		// 验证是否绑定手机号
		if(checkPhone && !store.state.user.phone){
			uni.showToast({
				title: '请先登录',
				icon: 'none'
			});
			return uni.navigateTo({
				url: '/pages/user-phone/user-phone'
			});
		}
	}
	callback()
}
// 验证登录跳转
Vue.prototype.navigateTo = (options,checkPhone=true)=> {
	if(!store.state.loginStatus) {
		uni.showToast({
			title:'请先登录',
			icon:'error'
		})
		return uni.navigateTo({
			url:'/pages/login/login'
		})
		// 验证是否绑定手机号
		if(checkPhone && !store.state.user.phone){
			uni.showToast({
				title: '请先登录',
				icon: 'none'
			});
			return uni.navigateTo({
				url: '/pages/user-phone/user-phone'
			});
		}
	}
	uni.navigateTo(options)
}
App.mpType = 'app'
const app = new Vue({
	store,
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif